{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=673
  Verdict: Accepted
}
var s:string; a:array[1..61,1..61] of int64; i,j:integer;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
readln(s);
for i:=1 to length(s) do fillchar(a[i],sizeof(a[i]),0);
for i:=1 to length(s) do a[i][i]:=1;
for i:=2 to length(s) do begin
    for j:=i-1 downto 1 do begin
        if a[j][i]=0 then begin
           if s[i]=s[j] then begin
              a[j][i]:=a[j][i-1]+a[j+1][i]+1;
           end else begin
               a[j][i]:=a[j][i-1]+a[j+1][i]-a[j+1][i-1];
           end;
        end;
    end;
end;
writeln(a[1][length(s)]);
end.